import {Customer, HouseOwner, Tenant} from './Customers';

interface Agent{
  contact(message:string, customer:Customer):void;
}

class EstateAgent implements  Agent{
  houseOwner:HouseOwner;
  tenant:Tenant;
  contact(message:string, customer:Customer):void{
    if(customer === this.houseOwner){
      console.log('中介转达消息，让房客接收消息');
      this.tenant.getMessage(message);
    }
    if(customer === this.tenant){
      console.log('中介转达消息，让房东接收消息');
      this.houseOwner.getMessage(message);
    }
  }

  setHouseOwner(houseOwner:HouseOwner):void{
    this.houseOwner = houseOwner;
  }
  setTenant(tenant:Tenant):void{
    this.tenant = tenant;
  }
}

export {Agent, EstateAgent};